package com.dyh.quickdemo.demos.lbdand;

import lombok.extern.slf4j.Slf4j;

import java.util.Random;

/*
@Author=Joey Wheeler
@Date=2020/12/8 9:38
*/
@Slf4j
public class TaobaoClient {

    BaseTaobaoRsp exe(BaseTaobaoReq req){
        BaseTaobaoRsp rsp = new BaseTaobaoRsp();
        Random random = new Random();
        long timeToSleep = 10*random.nextInt(10);

        try {
            Thread.sleep(timeToSleep);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        log.info("调用淘宝接口耗时:{}",timeToSleep);
        rsp.setSuccess(true);
        if ("expired".equals(req.token)){
            rsp.setSuccess(false);
            rsp.setMsg("授权过期");
        }
        return rsp;
    }
}
